<?php
namespace app\admin\controller;
use app\admin\controller\BaseController;
use app\common\errcode\AdminErrCode;
use app\common\errcode\AdminErrMsg;
use think\Loader;

class UserController extends BaseController
{
    protected $userModel;

    public function __construct()
    {
        parent::__construct();
        $this->userModel = new \app\admin\model\UserModel();
    }

    /**
     * 用户列表
     * @param   string  $company    公司     
     * @param   string  $username   用户姓名
     * @param   int     $pagesize   页码大小
     * @param   int     $page       页码
     * @return  string
     */
    public function index()
    {
        try {
            if($this->request->isPost()){
                $data = $this->request->post();
                return $this->jsonJump(AdminErrCode::SUCCESS,AdminErrMsg::SUCCESS,$this->userModel->list($data));
            }    
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->uid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }
    }

    /**
     * 创建用户
     * @param string $username   用户名
     * @param string $email      邮箱
     * @param string $password   密码
     * @param int    $type       用户类型 管理员:1 普通用户:2
     * @param string $remark     备注
     * @return string
     */
    public function create()
    {
        try {
            if($this->request->isPost()){
                
            }    
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->uid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }    
    }

    /**
     * 删除
     * @param int $uid
     */
    public function delete()
    {
        try {
            if($this->request->isPost()){
                
            }    
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->uid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }
    }

    /**
     * 用户编辑
     * @param   string  $method     方法:编辑文生图次数:editPictureNum
     * @param   int     $pictureNum 文生图次数  
     * @param   int     $userid     用户userid,字符串形式的 SS2023030001  
     */
    public function edit()
    {
        try {
            if($this->request->isPost()){
                
            }
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->uid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }    
    }

}